
package proyecto1;

public class FormularioDemandante extends javax.swing.JDialog {

    int contador=0;
    public FormularioDemandante(java.awt.Frame parent, boolean modal) { // muestra el formulario del demandante
        super(parent, modal);
        initComponents();
        mostrarDato();
       this.setLocationRelativeTo(null);
        this.setVisible(true);
    }
    
    public void mostrarDato(){
       Demandantes dem = new Demandantes();
       dem = (Demandantes)(Main.datosDem.get(contador));
       textoNombre.setText(dem.getNombre());
       textoRut.setText(dem.getRut());
       TextoProfesion.setText(dem.getProfesion());
       TextoTelefono.setText(dem.getTelefono());
       TextoDireccion.setText(dem.getDireccion());
       TextoCarnet.setText(dem.getClaseCarnetm());
       TextoNumeroT.setText(dem.getNumeroT());
       TextoUniversidad.setText(dem.getUniversidad());
       TextoEspecialidad.setText(dem.getEspecialidad());
       
       numero.setText((contador+1) +"/"+ Main.contador);
    }
    
    

    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        textoRut = new javax.swing.JLabel();
        textoNombre = new javax.swing.JLabel();
        Siguiente = new javax.swing.JButton();
        Atras = new javax.swing.JButton();
        numero = new javax.swing.JLabel();
        TextoVolver = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        TextoProfesion = new javax.swing.JLabel();
        Borrar = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        TextoTelefono = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        TextoDireccion = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        TextoCarnet = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        TextoEspecialidad = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        TextoUniversidad = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        TextoNumeroT = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setText("Nombre: ");

        jLabel3.setText("Rut: ");

        textoRut.setText("jLabel4");

        textoNombre.setText("jLabel5");

        Siguiente.setText("Siguiente");
        Siguiente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SiguienteActionPerformed(evt);
            }
        });

        Atras.setText("Atrás");
        Atras.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AtrasActionPerformed(evt);
            }
        });

        numero.setText("jLabel4");

        TextoVolver.setText("Volver al menú");
        TextoVolver.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TextoVolverActionPerformed(evt);
            }
        });

        jLabel4.setText("Profesion:");

        TextoProfesion.setText("jLabel5");

        Borrar.setText("Borrar Demandante");
        Borrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BorrarActionPerformed(evt);
            }
        });

        jLabel5.setText("Telefono: ");

        jLabel6.setFont(new java.awt.Font("Lucida Grande", 1, 24)); // NOI18N
        jLabel6.setText("Demandante");

        TextoTelefono.setText("jLabel7");

        jLabel7.setText("Dirección: ");

        TextoDireccion.setText("jLabel8");

        jLabel8.setText("Clase Carnet: ");

        TextoCarnet.setText("jLabel9");

        jLabel9.setText("Especialidad: ");

        TextoEspecialidad.setText("jLabel10");

        jLabel10.setText("Universidad: ");

        TextoUniversidad.setText("jLabel11");

        jLabel11.setText("Numoro de titulaciones: ");

        TextoNumeroT.setText("jLabel12");

        jLabel12.setFont(new java.awt.Font("Lucida Grande", 1, 18)); // NOI18N
        jLabel12.setText("Curriculum: ");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap(6, Short.MAX_VALUE)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(78, 78, 78)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jLabel8)
                                    .add(jLabel5)
                                    .add(jLabel4)
                                    .add(jLabel3)
                                    .add(jLabel1)
                                    .add(TextoVolver)
                                    .add(jLabel7)
                                    .add(jLabel12))
                                .add(28, 28, 28)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                                                        .add(Borrar)
                                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                        .add(Atras)
                                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                        .add(Siguiente)
                                                        .add(57, 57, 57))
                                                    .add(layout.createSequentialGroup()
                                                        .add(jLabel2)
                                                        .addContainerGap()))
                                                .add(layout.createSequentialGroup()
                                                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                                        .add(textoRut)
                                                        .add(TextoTelefono))
                                                    .addContainerGap()))
                                            .add(layout.createSequentialGroup()
                                                .add(textoNombre)
                                                .addContainerGap()))
                                        .add(layout.createSequentialGroup()
                                            .add(TextoProfesion)
                                            .addContainerGap()))
                                    .add(layout.createSequentialGroup()
                                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(TextoDireccion)
                                            .add(TextoCarnet))
                                        .addContainerGap())))
                            .add(layout.createSequentialGroup()
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jLabel11)
                                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                        .add(jLabel9)
                                        .add(jLabel10)))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(TextoUniversidad)
                                    .add(TextoNumeroT)
                                    .add(TextoEspecialidad, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 241, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                .add(215, 215, 215))))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(jLabel6)
                        .add(206, 206, 206)
                        .add(numero)
                        .add(87, 87, 87))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(20, 20, 20)
                        .add(numero))
                    .add(layout.createSequentialGroup()
                        .add(12, 12, 12)
                        .add(jLabel6)))
                .add(18, 62, Short.MAX_VALUE)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(jLabel2)
                    .add(textoNombre, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(7, 7, 7)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(textoRut)
                    .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(TextoProfesion)
                    .add(jLabel4))
                .add(22, 22, 22)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(TextoTelefono)
                            .add(jLabel5))
                        .add(59, 59, 59))
                    .add(layout.createSequentialGroup()
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(TextoDireccion)
                            .add(jLabel7))))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 26, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(TextoCarnet))
                .add(29, 29, 29)
                .add(jLabel12)
                .add(21, 21, 21)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(TextoNumeroT)
                    .add(jLabel11))
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel10)
                    .add(TextoUniversidad))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel9)
                    .add(TextoEspecialidad, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 104, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(126, 126, 126)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(Siguiente)
                    .add(Atras)
                    .add(TextoVolver)
                    .add(Borrar))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void SiguienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SiguienteActionPerformed
//rescribe el texto para el siguiente contador
    if(contador<Main.contador -1){
        contador++;
        mostrarDato();
    }
}//GEN-LAST:event_SiguienteActionPerformed

private void AtrasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AtrasActionPerformed
   if(contador>0){
        contador--;
        mostrarDato();
    }
}//GEN-LAST:event_AtrasActionPerformed

private void TextoVolverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TextoVolverActionPerformed
this.setVisible(false);
}//GEN-LAST:event_TextoVolverActionPerformed

private void BorrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BorrarActionPerformed
Main.datosDem.remove(contador);
if(contador!=0){
 contador--;   
}

Main.contador--;
if(Main.contador!=0){ // si es distinto es porque quedan personas   
   mostrarDato(); 
}else {
    this.setVisible(false); // para que se cierre la ventana
}

}//GEN-LAST:event_BorrarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FormularioDemandante.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FormularioDemandante.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FormularioDemandante.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FormularioDemandante.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                FormularioDemandante dialog = new FormularioDemandante(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Atras;
    private javax.swing.JButton Borrar;
    private javax.swing.JButton Siguiente;
    private javax.swing.JLabel TextoCarnet;
    private javax.swing.JLabel TextoDireccion;
    private javax.swing.JLabel TextoEspecialidad;
    private javax.swing.JLabel TextoNumeroT;
    private javax.swing.JLabel TextoProfesion;
    private javax.swing.JLabel TextoTelefono;
    private javax.swing.JLabel TextoUniversidad;
    private javax.swing.JButton TextoVolver;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel numero;
    private javax.swing.JLabel textoNombre;
    private javax.swing.JLabel textoRut;
    // End of variables declaration//GEN-END:variables
}
